<?php

namespace App\Http\Controllers\Api;

use App\Interface\CurdController;
use App\Librarys\Message;
use App\Models\PasswordTypeModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class PasswordTypeController extends BaseController implements CurdController
{
    protected Request $request;
    protected Model $passwordTypeModel;


    // 控制器初始化
    public function __construct(Request $request, PasswordTypeModel $passwordTypeModel)
    {
        $this->request = $request;
        $this->passwordTypeModel = $passwordTypeModel;
    }

    public function create()
    {
    }

    // 获取密码类型列表
    public function query()
    {
        // 获取flag
        $flag = $this->request->flag;
        switch ($flag) {
            default: // 默认flag
                return Message::show(false, '未定义操作');
                break; // 选择器格式
            case 'select':
                // 获取全部密码类型，因为数量不会太多，默认就全部获取了，对性能也没啥太大的影响
                $list = $this->passwordTypeModel->get();
                return Message::show(true, '获取成功', $list);
                break;
        }
    }

    public function delete()
    {
    }
}
